package com.chenyao.bookstore.dataprovider.processor.impl;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.chenyao.bookstore.dataprovider.processor.IResultProcessor;
import com.chenyao.bookstore.entity.User;

public class UserResultProcessorImpl implements IResultProcessor<User> {

	@Override
	public List<User> process(final ResultSet results) throws SQLException {
		List<User> list = new ArrayList<User>();
		while (results.next()) {
			User user = new User();
			user.setId(results.getInt(User.COLUMN_ID));
			user.setUsername(results.getString(User.COLUMN_USERNAME));
			user.setPassword(results.getString(User.COLUMN_PASSWORD));
			user.setCreateData(results.getDate(User.COLUMN_CREATEDATE));
			list.add(user);
		}
		return list;
	}

}
